<?php
////$class = new Zend_Reflection_Class();
?>
<div id="tabs">
    <ul>
        <li><a href="#tabs-1">Class Inspector</a></li>
        <li><a href="#tabs-2">Source Browser</a></li>
    </ul>
    <div id="tabs-1">
        <h1><?= $this->class->getName();?></h1>
        <?php
            $extends = $this->class->getParentClass();
            if($extends) {
                if(substr($extends->getName(), 0, 4) != 'Zend') {
                    $extendsString = "<a class='inspect_class' href='{$extends->getName()}'>{$extends->getName()}</a>";
                } else {
                    $extendsString = $extends->getName();
                }
                echo "<p><strong>Extends:</strong> {$extendsString}</p>";
            }
        ?>
        <p class="short_description"><?= $this->class->getDocblock()->getShortDescription();?>
        <?php foreach ($this->class->getMethods() as $method) {
            if(substr($method->getDeclaringClass()->getName(), 0, 4) != 'Zend') { ?>
                <div class="method">
                    <?php 
                            $params = array();
                            $tags = $method->getDocblock()->getTags();
                            $args = null;
                            if($tags) {
                                $args = null;
                                foreach ($tags as $tag) {
                                    if($tag instanceof Zend_Reflection_Docblock_Tag_Param) {
                                        $args[] = $tag->getVariableName();
                                        $params[] = '<tr><td class="ui-widget-content">' . str_replace(',', '', $tag->getVariableName()) . '&nbsp;</td>' .
                                                '<td class="ui-widget-content">' . $tag->getType() . '&nbsp;</td>' .
                                                '<td class="ui-widget-content">' . $tag->getDescription() . '&nbsp;</td></tr>';
                                    }
                                }
                                if(is_array($args)) {$args = implode(', ', $args);}
                            }
                    ?>
                    <h3 class="ui-state-default ui-corner-all"><?= $method->getName();?>(<?= $args ?>)</h3>
                    <div class="method_content">
                        <?php
                            $declaredBy = $method->getDeclaringClass();
                            if($declaredBy && $declaredBy->getName() != $this->class->getName()) {
                                echo "<p><strong>Declared By:</strong> <a class='inspect_class' href='{$declaredBy->getName()}'>{$declaredBy->getName()}</a></p>";
                            }
                        ?>
                        <p class="short_description"><?= $method->getDocblock()->getShortDescription();?></p>
                        <p class="long_description"><?= $this->digCmsTextile($method->getDocblock()->getLongDescription());?></p>
                        <?php if($method->getDocblock()->hasTag('example')) { ?>
                            <p class="example"><strong>Example: </strong> <code><?= $method->getDocblock()->getTag('example')->getDescription();?></code></p>
                        <?php }
                            if(count($params) > 0) {
                            ?>
                            <table class="params ui-widget-content" cellpadding="0" cellspacing="0">
                                <tr class="ui-state-default">
                                    <th class="even_col">Parameter</th>
                                    <th>Type</th>
                                    <th>Description</th>
                                </tr>
                                <?php echo implode(PHP_EOL, $params);?>
                            </table>
                            <?php }else{ ?>
                            <p class="params">This method does not have any parameters.</p>
                        <?php } ?>
                        <?php if($method->getDocblock()->hasTag('return')) { ?>
                            <p class="example"><strong>Returns: </strong> 
                                <code><?= $method->getDocblock()->getTag('return')->getType();?>
                                    <?= $method->getDocblock()->getTag('return')->getDescription();?></code>
                            </p>
                        <?php } ?>
                    </div>
                </div>
            <?php }}?>
    </div>
    <div id="tabs-2">
        <pre name="code" class="php">
            <?php echo htmlentities(trim(file_get_contents($this->class->getFileName())));?>
        </pre>
    </div>
</div>
<script type="text/javascript">
    $('table.params tr:odd').addClass('odd');
    $("#tabs").tabs();
    dp.SyntaxHighlighter.ClipboardSwf = '/jquery/dp.SyntaxHighlighter/Scripts/clipboard.swf';
    dp.SyntaxHighlighter.HighlightAll('code');
</script>
